This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
Custom error messages with validation message tag helper #8035
Labels
3 - Done
bug
cost: S
Will take up to 2 days to complete
PRI: 2 - Preferred
Preferably should be handled during the milestone.
Milestone
Comments
@mkArtakMSFT since the current behaviour is counter-intuitive, suggest we update |
Sounds good, @dougbu. |
mkArtakMSFT
added
bug
1 - Ready
PRI: 2 - Preferred
Preferably should be handled during the milestone.
labels
Jul 10, 2018
kishanAnem
pushed a commit
to kishanAnem/Mvc
that referenced
this issue
Jul 15, 2018
Thanks to @kishanAnem for PR #8087. He's well on the way to fixing this issue. |
@dougbu welcome. :) . I'm glad to work with you. |
kishanAnem
pushed a commit
to kishanAnem/Mvc
that referenced
this issue
Jul 21, 2018
I think I fiexed this time.
kishanAnem
pushed a commit
to kishanAnem/Mvc
that referenced
this issue
Jul 22, 2018
dougbu
added a commit
that referenced
this issue
Jul 22, 2018
Custom error messages with validation message tag helper #8035
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
3 - Done
bug
cost: S
Will take up to 2 days to complete
PRI: 2 - Preferred
Preferably should be handled during the milestone.
Is this a Bug or Feature request?:
Feature request or documentation request
Steps to reproduce (preferably a link to a GitHub repo with a repro project):
Add a simple model and a view that uses the validation message tag helper.
<span asp-validation-for="Name">Custom error message</span>
Validation message is displayed as "The Name field is required" rather than "Custom error message"
Description of the problem:
Simple workaround is to add the data-valmsg-replace="false" along with the asp-validation-for attribute.
<span asp-validation-for="Name" data-valmsg-replace="false">Custom error message</span>
The ValidationMessageTagHelper does check for inner content but the data-valmsg-replace attribute has already been set to true at this point as a null message parameter is passed to the HtmlGenerator. Ideally the data-valmsg-replace would be set to false at this point if the element has inner content. Alternatively change the validation message documentation to show how to set the data-valmsg-replace attribute for custom error messages.
Version of
Microsoft.AspNetCore.Mvc
orMicrosoft.AspNetCore.App
orMicrosoft.AspNetCore.All
:2.1.1
The text was updated successfully, but these errors were encountered: